﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<unordered_map>

using namespace std;

class Solution {
public:

    //⻓度最⼩的⼦数组
    int minSubArrayLen(int target, vector<int>& nums)
    {
        int left = 0;
        int right = 0;
        int len = INT_MAX;
        int sum = 0;
        int flag = 0;
        while (right < nums.size())
        {
            sum += nums[right];
            if (sum >= target)
            {
                while (sum >= target)
                {
                    flag = 1;
                    len = min(len, right - left + 1);
                    sum -= nums[left++];
                }
            }
            right++;
        }
        return flag ? len : 0;
    }

    //无重复字符的最长子串
    int lengthOfLongestSubstring(string s)
    {
        unordered_map<char, int> um;
        int left = 0;
        int right = 0;
        int len = INT_MIN;
        while (right < s.size())
        {
            um[s[right]]++;
            while (um[s[right]] == 2)
            {
                um[s[left]]--;
                left++;
            }
            len = max(len, right - left + 1);
            right++;
        }
        return len == INT_MIN ? 0 : len;
    }

    //最大连续1的个数 III
    int longestOnes(vector<int>& nums, int k)
    {
        int len = INT_MIN;
        int count = 0;
        for (int left = 0, right = 0; right < nums.size(); right++)
        {
            if (nums[right] == 0)
            {
                count++;
            }
            while (count > k)
            {
                if (nums[left] == 0)
                {
                    count--;
                }
                left++;
            }
            len = max(len, right - left + 1);
        }
        return len == INT_MIN ? 0 : len;
    }




};


int main()
{

	return 0;
}